package com.cloud.basic.test;

import com.google.common.base.Splitter;
import com.google.common.collect.Lists;

import java.awt.*;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.Stack;

/**
 * @program: basic
 * @description: 堆和栈
 * @author: Cloud
 * @create: 2020/11/18 09:50:10
 */
public class HeapAndStack {

    public static void main(String[] args) {
        // 栈
        Stack stack = new Stack();
        stack.push("123");
        stack.push("456");
        stack.push("789");
        stack.push("abc");
        System.out.println(stack.peek().toString());
        System.out.println(stack.search("123"));
        System.out.println("stack.lastElement() = " + stack.lastElement());
        System.out.println("stack.firstElement() = " + stack.firstElement());
        stack.forEach(y-> System.out.println("y = " + y ));

        // 队列
        List<String> list = Splitter.on("1,2,3,4,5,6,7").splitToList(",");
        Queue queue = new LinkedList<>();
        queue.add(1);
        queue.add("2");
        queue.add("3");
        queue.add("4");
        queue.add("5");
        queue.forEach(x-> System.out.println("x = " + x));
        System.out.println(queue.peek().toString());
    }
}
